/*
 * Copyright 2011 Philippe Blanc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package me.l1k3.fx.client.channel.trait;

public class TraitDecorator extends Trait {
    private String unit;
    private boolean integer;
    
    //- - -
    
    public final void set(int diff) {
        super.set(diff);
        integer = true;
    }
    
    public final void set(int start, int end) {
        super.set(start, end);
        integer = true;
    }
    
    public final void setUnit(String unit) {
        this.unit = unit;
    }
    
    public final void setInteger(boolean integer) {
        this.integer = integer;
    }
    
    //- - -
    
    public final String getString(boolean backward) {
        return integer? ((int)get(backward))+unit : get(backward)+unit;
    }
    
    public final String updateString(boolean backward, double progress) {
        return integer? ((int)update(backward, progress))+unit : update(backward, progress)+unit;
    }
}
